home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 October: Technology Seed / ADC Seed CD - October 1999.toast / FireWire / FireWire_2.1_SDK_DR3 / Source / FWiX / FWiXApp / FWiXmain.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-05-17  |  10.1 KB  |  394 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FWXmain.h
  3.  
  4.     Contains:    Definitions for FireWire File Exchange application.
  5.  
  6.     Version:    1.0
  7.  
  8.     Written by:    Jay Lloyd
  9.  
  10.     Copyright:    © 1996-1998 by Apple Computer, Inc., all rights reserved.
  11.  
  12.     File Ownership:
  13.  
  14.         DRI:                Jay Lloyd
  15.  
  16.         Other Contact:        
  17.  
  18.         Technology:            FireWire
  19.  
  20.     Writers:
  21.  
  22.         (jkl)    Jay Lloyd
  23.  
  24.     Change History (most recent first):
  25.  
  26.         <24>     1/15/98    jkl        Update for new headers.
  27.       <FW23>     6/19/97    jkl        Added another preference flag for icon view. Made preferences a
  28.                                     long instead of a byte. Added AppleScript defines and an
  29.                                     AppleEvent send queue definition.
  30.       <FW22>     6/10/97    jkl        Moved QDGlobals to main.c global for easier code warrior
  31.                                     compiles.
  32.       <FW21>     5/27/97    jkl        Added room for 4 byte packet index to control packet buffers.
  33.       <FW20>     5/15/97    jkl        Added routine declarations.
  34.       <FW19>      5/7/97    jkl        Updated list data structures with a previous pointer to make
  35.                                     them double linked lists.
  36.       <FW18>     4/29/97    jkl        Added declarations for some new routines and added a busyAlert
  37.                                     resource ID.
  38.       <FW17>      4/8/97    jkl        Added key definitions for page up, page down, home and end for
  39.                                     keyboard scrolling. Changed my initials.
  40.       <FW16>     3/18/97    jkl        Moved prefs related definitions to prefs.h.
  41.       <FW15>     2/27/97    jkl        Modified constants for file conflict preferences to be under
  42.                                     receiver control. Added constants for scrolling support in
  43.                                     sender window.
  44.       <FW14>     2/21/97    jkl        Got rid of unused constants and added memory error alert.
  45.       <FW13>     2/19/97    jkl        Adjusted counts and sizes of buffers.
  46.       <FW12>     2/13/97    jkl        Modified count and size of buffers.
  47.       <FW11>     2/13/97    jkl        Modified count and size of buffers.
  48.       <FW10>     2/11/97    jkl        Added queue definitions, modified buffer numbers and sizes.
  49.        <FW9>      2/2/97    jkl        Modified resource definitions to match HI spec.
  50.        <FW8>     1/27/97    ES        Added defs for FW Control PB queue.
  51.        <FW7>     1/27/97    jkl        Added error alert resource id's and error constants. Updated
  52.                                     menu constants. Added a sendflags field to the send queue.
  53.                                     Defined a pre-send check queue record and my timer task record
  54.                                     with node id on the end.
  55.        <FW6>     1/16/97    jkl        Changed notify sound resource preference to not conflict with
  56.                                     another string resource.
  57.        <FW5>     1/16/97    jkl        Added new user interface features. Constants for notification
  58.                                     and preferences dialog.
  59.        <FW4>    11/13/96    jkl        Added data structure to handle receives from multiple machines.
  60.        <FW3>     10/16/96    jkl        Modified queue structure for send queue to handle
  61.                                     multiple files and folders.
  62.        <FW2>     10/16/96    jkl        renamed constants for clarity, changed number
  63.                                        and sizes of buffers for performance experiments
  64.        <FW1>     10/2/96    jkl        initial check-in
  65. */
  66.  
  67. #ifndef __FWXMAIN__
  68. #define __FWXMAIN__
  69.  
  70. #include <Drag.h>
  71. #include <Timer.h>
  72.  
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76.  
  77. #if PRAGMA_IMPORT_SUPPORTED
  78. #pragma import on
  79. #endif
  80.  
  81. #if PRAGMA_ALIGN_SUPPORTED
  82. #pragma options align=mac68k
  83. #endif
  84.  
  85. #define kDITop            0x0050
  86. #define kDILeft            0x0070
  87.  
  88. #define    kFileReadBufs        2                // number of buffers to allocate for file reads
  89. #define kFileReadBufSize    (32*1024)        // buffer size for file reads
  90.  
  91. #define kFWControlParams    20                // number of param blocks to allocate for control packets
  92. #define kFWControlParamBufferSize    (sizeof (CInfoPBRec) + 8)        // size of control packet buffer, big enough for CatInfo
  93.  
  94. #define kFWReadControlBufs    20                // number of read control buffers to pass to driver
  95. #define kFWReadControlBufSize        (sizeof (CInfoPBRec) + 8)        // size of read control buffers
  96.  
  97. #define kFWReadDataBufs        6                // number of read data buffers to pass to driver
  98. #define kFWReadDataBufSize    (32*1024)        // size of read data buffers
  99.  
  100. #define    kCanSelectDesktop    true
  101.  
  102. // error constants
  103. enum
  104. {
  105.     kItemExistsError        = 1,
  106.     kSpaceError                = 2,
  107.     kUnknownError            = -1
  108. };
  109.  
  110. enum
  111. {
  112.     // Apple event class for FireWire File Exchange driver family.
  113.     kAEFWXSendEventID    = 'send',
  114.     kAEFWXNodeListID    = 'node',
  115.     kAEFWXNodeKeyword    = 'node'
  116. };
  117.  
  118. // prefs constants
  119. enum
  120. {
  121.     kNoNotificationPosted    = 0,
  122.     kNotificationPosted        = 1,
  123.     
  124.     // the preferences are stored as a long with these bit fields
  125.     kConflictCancel            = 0x01,
  126.     kConflictRename            = 0x02,
  127.     kConflictOverwrite        = 0x04,
  128.     kNotifyFlash            = 0x10,
  129.     kNotifyAlert            = 0x20,
  130.     kNotifySound            = 0x40,
  131.     kNotifyOpen                = 0x80,
  132.     kIconView                = 0x100            // if bit is clear: large icon, set: small icon
  133. };
  134.  
  135. // resource and menu constants
  136. enum
  137. {
  138.     kMenuBarResourceID        = 128,
  139.     kWindowResourceID        = 128,
  140.         
  141.     kAboutAlertResourceID    = 128,
  142.     kNoNameAlertID            = 130,
  143.     kUnknownErrAlertID        = 133,
  144.     kSpaceErrAlertID        = 134,
  145.     kCantQuitAlertID        = 136,
  146.     kCommunicationErrorAlertID    = 137,
  147.     kNodeDisconnectAlertID    = 138,
  148.     kMemoryErrorAlertID        = 139,
  149.     kIOErrorAlertID            = 140,
  150.     kRecvErrorAlertID        = 141,
  151.     kItemExistsErrAlertID    = 142,
  152.     kItemBusyErrAlertID        = 143,
  153.     kNSVErrAlertID            = 144,
  154.     kReceiveAlertID            = 145,
  155.     kReceiverQuitAlertID    = 146,
  156.  
  157.     kAppleMenuID             = 128,
  158.     kAboutMenuItem             = 1,
  159.     
  160.     kFileMenuID                = 129,
  161.     kOpenMenuItem            = 1,
  162.     kCloseMenuItem            = 2,
  163.     kOpenDropMenuItem        = 4,
  164.     kQuitMenuItem            = 6,
  165.  
  166.     kEditMenuID                = 130,
  167.     kPrefsMenuItem            = 8,
  168.  
  169.     kViewMenuID                = 131,
  170.     kSmallIconMenuItem        = 1,
  171.     kIconMenuItem            = 2,
  172.     
  173.     kPrefsDlogID            = 131,
  174.     kOKButton                = 1,
  175.     kCancelButton            = 2,
  176.     kFlashBox                = 3,
  177.     kAlertBox                = 4,
  178.     kSoundBox                = 5,
  179.     kOpenBox                = 6,
  180.     kSoundPopup                = 7,
  181.     kDropName                = 9,
  182.     kDropButton                = 10,
  183.     kCancelRadio            = 12,
  184.     kRenameRadio            = 13,
  185.     kOverwriteRadio            = 14,
  186.     kDefaultUserItem        = 16,
  187.     
  188.     kReturnKey                = 13,
  189.     kEnterKey                = 3,
  190.     kEscapeKey                = 27,
  191.     kPeriodKey                = 46,
  192.     kPageUpKey                = 11,
  193.     kPageDownKey            = 12,
  194.     kHomeKey                = 1,
  195.     kEndKey                    = 4,
  196.  
  197.     kProgressPrompt            = 2,
  198.     kProgressBarUserItem    = 4,
  199.     kCopyProgressDlog        = 129,
  200.     
  201.     kVScrollBar                = 128,    
  202.     kHScrollBar                = 129,
  203.     
  204.     kDropIconSuiteID        = 128,
  205.     kAppIconSuiteID            = 129,
  206.     kNotifyIcon                = 128,
  207.     kNotifyString            = 128,
  208.     kNetworkNameID            = -16413
  209. };
  210.  
  211. // scroll bar offset constants
  212. enum
  213. {
  214.     kScrollBarWidth            = 16,
  215.     kScrollBarAdjust        = kScrollBarWidth - 1,
  216.     kScrollBarTweek            = 2
  217. };
  218.  
  219. // global data for Drag Manager handlers
  220. struct DragHandlerGlobals {
  221.     Boolean        acceptableDragFlag;
  222.     short        hilitedSpace;
  223. };
  224. typedef struct DragHandlerGlobals DragHandlerGlobals, *DragHandlerGlobalsPtr;
  225.  
  226.  
  227. // global data for application
  228. struct FWXAppStruct
  229. {
  230.     DragHandlerGlobals            dragHandlerGlobals;
  231.     
  232.     AEEventHandlerUPP            openApplicationEventHandler;
  233.     AEEventHandlerUPP            openDocumentsEventHandler;
  234.     AEEventHandlerUPP            quitApplicationEventHandler;
  235.     AEEventHandlerUPP            fileSpecListHandler;
  236.     AEEventHandlerUPP            sendItemsEventHandler;
  237.     AEEventHandlerUPP            getNodeListEventHandler;
  238.     DragTrackingHandlerUPP        dragTrackingHandler;
  239.     DragReceiveHandlerUPP        dragReceiveHandler;
  240.     DragReceiveHandlerUPP        deviceAddedEventHandler;
  241.     DragReceiveHandlerUPP        deviceRemovedEventHandler;
  242.     IOCompletionUPP                fileWriteCompletionHandler;
  243.     IOCompletionUPP                fileReadCompletionHandler;
  244.     
  245.     FWXClientID                    fwxClientID;
  246.  
  247.     WindowPtr                    pSenderWindow;
  248.     
  249.     NMRecPtr                    pNotifyRec;
  250.     
  251.     FSSpec                        fwixReceiveFolder;
  252.     Str31                        fwixNotifySound;
  253.     UInt32                        fwixPrefs;
  254.     
  255.     Boolean                        getNodeListEventHandlerInstalled;
  256.     Boolean                        sendItemsEventHandlerInstalled;
  257.     Boolean                        deviceRemovedEventHandlerInstalled;
  258.     Boolean                        deviceAddedEventHandlerInstalled;
  259.     Boolean                        dragReceiveHandlerInstalled;
  260.     Boolean                        dragTrackingHandlerInstalled;
  261.     Boolean                        fileSpecListHandlerInstalled;
  262.     Boolean                        quitApplicationEventHandlerInstalled;
  263.     Boolean                        openDocumentsEventHandlerInstalled;
  264.     Boolean                        openApplicationEventHandlerInstalled;
  265.     Boolean                        quitFlag;    
  266.     Boolean                        inForeground;
  267. };
  268. typedef struct FWXAppStruct        FWXAppData,
  269.                                 *FWXAppDataPtr;
  270.  
  271.  
  272. typedef struct FWXPacketStruct FWXPacket, *FWXPacketPtr;
  273. struct FWXPacketStruct
  274. {
  275.     UInt32                    packetIndex;
  276.     UInt32                    packetType;
  277.     Ptr                        packetData;
  278. };
  279.  
  280.  
  281. typedef struct TxFsSpecQueueStruct TxFSSpec, *TxFSSpecPtr;
  282. struct TxFsSpecQueueStruct
  283. {
  284.     QElemPtr                qLink;
  285.     FSSpecPtr                pFSSpec;
  286.     FWXNodeID                recvNode;
  287.     UInt32                    itemType;
  288. };
  289.  
  290. typedef struct AESendQueueStruct AESendRec, *AESendRecPtr;
  291. struct AESendQueueStruct
  292. {
  293.     QElemPtr                qLink;
  294.     FSSpecPtr                pSendItemsList;
  295.     FWXNodeID                recvNode;
  296.     UInt16                    numSendItems;
  297. };
  298.  
  299. typedef struct NodeSendStruct NodeSendItem, *NodeSendItemPtr;
  300. struct NodeSendStruct
  301. {
  302.     NodeSendItemPtr            pNextSendItem,
  303.                             pPreviousSendItem;
  304.     FSSpec                    sendItemSpec;
  305.     UInt32                    itemSize;
  306. };
  307.  
  308. typedef struct MyTMTask MyTMTask, *MyTMTaskPtr;
  309. struct MyTMTask
  310. {
  311.     TMTask            timerTask;                // regular time struct
  312.     FWXNodeID        nodeID;                    // add node id since we will normally
  313.                                             // be using this for errors with nodes
  314. };
  315.  
  316. typedef struct CurFileQueueStruct CurFileInfo, *CurFileInfoPtr;
  317. struct CurFileQueueStruct
  318. {
  319.     QElemPtr                qLink;
  320.     FSSpecPtr                pCurFileSpec;
  321.     FWXNodeID                curFileSenderID;
  322.     UInt32                    forkLength;
  323.     UInt32                    recvLength;
  324.     SInt32                    curDirID;
  325.     SInt16                    curFileRefNum;
  326.     OSErr                    curError;
  327. };
  328.  
  329. OSErr HandlePrefsDialog (void);
  330. OSErr InitPrefs (void);
  331. void HandleIdle (void);
  332. OSErr GetCurFileInfo(
  333.     FWXNodeID                recvNodeID,
  334.     CurFileInfoPtr            *hCurFileInfo,
  335.     Boolean                    createNew);
  336. OSErr InitRecvFolder(
  337.     SInt32                    *dirID);
  338. void UpdateNotification (
  339.     NMRecPtr                pNMRec);
  340. OSErr SaveWindowPos (
  341.     WindowPtr                pWin);
  342. OSErr GetWindowPos (
  343.     Rect                    *r);
  344. void HandleUpdateEvent (
  345.     EventRecord                *pEventRecord);
  346. SInt16 HandleCautionAlert (
  347.     SInt16                    alertResID);
  348. SInt16 HandleStopAlert (
  349.     SInt16                    alertResID);
  350. SInt16 HandleNoteAlert (
  351.     SInt16                    alertResID);
  352. SInt16 HandleAlert (
  353.     SInt16                    alertResID);
  354. pascal OSErr HandleFileWriteComplete (
  355.     ParmBlkPtr                pFilePB);
  356. void HandleFWWriteComplete (
  357.     IOParamPtr                pFilePB);    
  358. void HandleFWControlComplete (
  359.     IOParamPtr                pFWPB);
  360. void HandleFWReadComplete (
  361.     IOParamPtr                pFilePB);
  362. pascal OSErr HandleFileReadComplete (
  363.     ParmBlkPtr                pFilePB);
  364. void SetupFileReadPB (
  365.     IOParamPtr                pb);
  366. void SetupFWWritePB(
  367.     IOParamPtr                pb);
  368. void SetupFWControlPB (
  369.     IOParamPtr                pb);
  370. OSErr FWIXDequeue (
  371.     QElemPtr                *ppQElem,
  372.     QHdrPtr                    pQHdr);
  373. OSErr UpdatePrefsFile (void);
  374. OSErr SendFSSpecListToSelf (
  375.     FWXNodeID                fwxNodeID,
  376.     FSSpecPtr                pFSSpecList,
  377.     UInt16                    numItems);
  378.  
  379.  
  380.  
  381. #if PRAGMA_ALIGN_SUPPORTED
  382. #pragma options align=reset
  383. #endif
  384.  
  385. #if PRAGMA_IMPORT_SUPPORTED
  386. #pragma import off
  387. #endif
  388.  
  389. #ifdef __cplusplus
  390. }
  391. #endif
  392.  
  393. #endif
  394.